using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Hostal.Bussines.Entities;

namespace Hostal.Bussines.Repository.Mapping
{
    public class InsumoMap : EntityTypeConfiguration<Insumo>
    {
        public InsumoMap()
        {
            // Primary Key
            this.HasKey(t => t.IdInsumos);

            // Properties
            this.Property(t => t.Nombre)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Insumos");
            this.Property(t => t.IdInsumos).HasColumnName("IdInsumos");
            this.Property(t => t.Proveedor_Id).HasColumnName("Proveedor_Id");
            this.Property(t => t.Nombre).HasColumnName("Nombre");
            this.Property(t => t.Stock).HasColumnName("Stock");

            // Relationships
            this.HasRequired(t => t.Proveedore)
                .WithMany(t => t.Insumos)
                .HasForeignKey(d => d.Proveedor_Id);

        }
    }
}
